home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
019a
/
opbgd113.zip
/
IDEMAIN.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-10-21
|
28KB
|
1,067 lines
{$A+,F+,O+,R-,S-,V-,X+}
unit IDEMain;
{$I OPDEFINE.INC}
{$IFNDEF UseMouse}
{$UNDEF UseDrag}
{$ENDIF}
interface
uses
DOS,
OpInline,
OpRoot,
OpDos,
OpString,
OpCrt,
OpKey,
OpCmd,
{$IFDEF UseMouse}
OpMouse,
{$IFDEF UseDrag}
OpDrag,
{$ENDIF}
{$ENDIF}
OpFrame,
OpWindow,
OpEdit,
OpPick,
OpDir,
OpBigEd,
ExecAccess;
{$IFDEF UseMouse}
const
MouseChar : Char = #04;
{$ENDIF}
procedure Main;
implementation
const
BigEditorColorsCfgID : String[19] = 'editor colors array';
BigEdColors : ColorSet = (
TextColor : $1B; TextMono : $0F;
CtrlColor : $1C; CtrlMono : $0F;
FrameColor : $13; FrameMono : $07;
HeaderColor : $20; HeaderMono : $70;
ShadowColor : $08; ShadowMono : $0F;
HighlightColor : $1E; HighlightMono : $70;
PromptColor : $0B; PromptMono : $07;
SelPromptColor : $0E; SelPromptMono : $07;
ProPromptColor : $08; ProPromptMono : $07;
FieldColor : $0B; FieldMono : $07;
SelFieldColor : $0F; SelFieldMono : $0F;
ProFieldColor : $08; ProFieldMono : $07;
ScrollBarColor : $07; ScrollBarMono : $07;
SliderColor : $0F; SliderMono : $0F;
HotSpotColor : $70; HotSpotMono : $70;
BlockColor : $30; BlockMono : $0F;
MarkerColor : $4F; MarkerMono : $70;
DelimColor : $1E; DelimMono : $0F;
SelDelimColor : $70; SelDelimMono : $0F;
ProDelimColor : $1E; ProDelimMono : $0F;
SelItemColor : $3E; SelItemMono : $70;
ProItemColor : $17; ProItemMono : $07;
HighItemColor : $1F; HighItemMono : $0F;
AltItemColor : $1F; AltItemMono : $0F;
AltSelItemColor : $3F; AltSelItemMono : $70;
FlexAHelpColor : $1F; FlexAHelpMono : $0F;
FlexBHelpColor : $1F; FlexBHelpMono : $0F;
FlexCHelpColor : $1B; FlexCHelpMono : $70;
UnselXrefColor : $1E; UnselXrefMono : $09;
SelXrefColor : $3F; SelXrefMono : $70;
MouseColor : $4F; MouseMono : $70
);
const
BigEditorColorsCfgEnd : Byte = 0;
const
MaxEds = 4;
SwapFilePath : PathStr = '\$BIGED$.SWP';
CfgFileName : PathStr = 'BE3.CFG';
const
PromptLine = 1;
StatusLine = 2;
NormMouse = $04;
MoveMouse = $12;
ResizeMouse = $1D;
type
CompType = (ctTPC, ctTPCX, ctTPCW, ctTASM, ctTD);
CompMode = (cmMake, cmBuild, cmErrSrch, cmCustom);
const
CompNames : Array[CompType] of String[4] =
('TPC ', 'TPCX', 'TPCW', 'TASM', 'TDbg');
const
ConfigBanner : String[10] = 'IDE config';
{You will want to adjust these as needed for your system config}
CompCmds : Array[CompType] of PathStr =
('C:\TP\TPC.EXE', {TPC}
'C:\TP\TPCX.EXE', {TPCX}
'C:\TPW\TPCW.EXE', {TPCW}
'C:\TP\TASM.EXE', {TASM}
'D:\TD\TD286.EXE'); {TD}
CompDefOpts : Array[CompType] of PathStr =
('/M /L', {TPC}
'/M /L', {TPCX}
'/M /L', {TPCW}
'', {TASM}
''); {TD}
const
ConfigEnd : Byte = 0;
type
SpcStateRec =
record
SSR : StreamStateRec;
CT : CompType;
end;
FileNodePtr = ^FileNode;
FileNode =
Object(DoubleListNode)
Path : PathStr;
State : SpcStateRec;
constructor Init(P : PathStr; var S : SpcStateRec);
destructor Done; virtual;
procedure Update(P : PathStr; var S : SpcStateRec);
end;
type
MyBigEditorPtr = ^MyBigEditor;
MyBigEditor =
object(BigEditor)
MainFile : PathStr;
NFName : PathStr;
Report : PathStr;
LC, CC : Integer;
CompileType : CompType;
CompileMode : CompMode;
constructor InitCustom(UX, UY, LX, LY : Byte;
var Colors : ColorSet;
WinOpts : LongInt);
destructor Done; virtual;
function FindCompileError : Boolean;
procedure FindCompileGood;
procedure CallCompiler(CType : CompType; CMode : CompMode);
procedure ShowBackground;
procedure DosShell(Cmd : String);
procedure ExecuteSelf;
procedure PerformDosCommand;
procedure SelectCompiler;
procedure SaveState(var S); virtual;
procedure RestoreState(var S); virtual;
procedure ReadFile(FName : string; var FSize : LongInt); virtual;
procedure SaveFile; virtual;
procedure NewFilePrompted; virtual;
end;
var
BE : MyBigEditorPtr;
TBW : StackWindowPtr;
FilesList : DoubleList;
function HasWildCards(S : PathStr) : Boolean;
begin
HasWildCards := (Pos('*',S) > 0) or (Pos('?',S) > 0);
end;
constructor FileNode.Init(P : PathStr; var S : SpcStateRec);
begin
if NOT DoubleListNode.Init then Fail;
FileNode.Update(P, S);
end;
destructor FileNode.Done;
begin
DoubleListNode.Done;
end;
procedure FileNode.Update(P : PathStr; var S : SpcStateRec);
begin
Path := StUpCase(P);
State := S;
end;
procedure FNamePickProc(Item : Word; Mode : pkMode;
var iType : pkItemType;
var IString : String;
PickPtr : PickListPtr);
var
P : FileNodePtr;
begin
P := FileNodePtr(FilesList.Nth(Item));
if P = nil then
IString := '** None **'
else
IString := ' '+P^.Path+' ';
end;
function WidestFName : Word;
var
P : FileNodePtr;
W : Word;
begin
P := FileNodePtr(FilesList.Head);
W := 0;
while P <> nil do begin
if Length(P^.Path) > W then
W := Length(P^.Path);
P := FileNodePtr(FilesList.Next(P));
end;
WidestFName := W;
end;
function FindFileInList(PS : PathStr) : FileNodePtr;
var P : FileNodePtr;
begin
PS := StUpCase(PS);
with FilesList do begin
P := FileNodePtr(Head);
while P <> NIL do begin
if P^.Path = PS then begin
FindFileInList := P;
exit;
end;
P := FileNodePtr(Next(P));
end;
FindFileInList := NIL;
end;
end;
procedure AddFileToList(PS : PathStr; var S : SpcStateRec);
var P : FileNodePtr;
begin
P := FindFileInList(PS);
if P = NIL then begin
New(P, Init(PS, S));
FilesList.Append(P);
end
else P^.Update(PS, S);
end;
{----------------------------------------------------------------------------}
procedure Status(BEP : BigEditorPtr);
const
FN : String[13] = '';
SL : String[80] =
{.........1.........2.........3.........4.........5.........6.........7.........8}
' Col: Line: SAVE Wrap Ins Ind Smart *ZOOM* 1 ';
var
S, L : String;
procedure Merge(T : String; Psn : Byte);
begin
Move(T[1], S[Psn], Length(T));
end;
procedure MergeNum(N : LongInt; Psn, PLen : Byte);
var
T : String[5];
begin
T := Long2Str(N);
T := Pad(T, PLen);
Merge(T, Psn);
end;
procedure MergeNumRight(N : LongInt; Psn, PLen : Byte);
var
T : String[5];
begin
T := Long2Str(N);
T := LeftPad(T, PLen);
Merge(T, Psn-Pred(PLen));
end;
begin
with MyBigEditorPtr(BEP)^ do begin
S := SL;
if beOptionsAreOn(beNewFile) then begin
FN := Pad(JustFileName(bePathName), 13);
beOptionsOff(beNewFile);
end;
Merge(FN, 4);
L := Long2Str(TNum+LOfs)+'∙'+Long2Str(LList^.Size);
Merge(L, 33);
MergeNum(CPos+COfs, 22, 4);
{ MergeNumRight(((MemAvail-MemSafetySize) div 1024), 50, 4); }
if not beOptionsAreOn(beModified) then
Merge(' ', 48);
if not beOptionsAreOn(beWordwrap) then
Merge(' ', 53);
if not beOptionsAreOn(beInsert) then
Merge('Ovr', 58);
if not beOptionsAreOn(beIndent) then
Merge(' ', 62);
if not beOptionsAreOn(beSmartTabs) then
Merge('Fixed', 66);
if not IsZoomed then
Merge(' ',72);
Merge(CompNames[CompileType], 43);
with BigEdColors do
FastWrite(S, wYL-1, 1, ColorMono(HeaderColor, HeaderMono));
end;
end;
procedure UserHook(CPP : CommandProcessorPtr; MT : MatchType; Key : Word);
{-Called each time CommandProcessor evaluates a keystroke}
var
S : string[2];
{$IFDEF UseMouse}
SaveMouse : Boolean;
{$ENDIF}
begin
S := ' ';
if MT = PartMatch then
if Lo(Key) < Ord(' ') then begin
S[1] := '^';
S[2] := Char(Lo(Key)+$40);
end
else
S[1] := '+';
{$IFDEF UseMouse}
HideMousePrim(SaveMouse);
{$ENDIF}
with BigEdColors do
FastWrite(S, StatusLine, 1, ColorMono(HeaderColor, HeaderMono));
{$IFDEF UseMouse}
ShowMousePrim(SaveMouse);
{$ENDIF}
end;
procedure ClearPromptLine;
begin
with BigEdColors do
FastWrite(CharStr(' ', ScreenWidth), PromptLine, 1,
ColorMono(PromptColor, PromptMono));
end;
procedure DisplayMessage(Msg : string);
{-Display a message at the top of the screen}
{$IFDEF UseMouse}
var
SaveMouse : Boolean;
{$ENDIF}
begin
{$IFDEF UseMouse}
HideMousePrim(SaveMouse);
{$ENDIF}
ClearPromptLine;
if Length(Msg) > ScreenWidth then Msg[0] := Chr(ScreenWidth);
with BigEdColors do
FastWrite(Msg, PromptLine, 1, ColorMono(PromptColor, PromptMono));
GotoXYabs(Length(Msg)+1, PromptLine);
{$IFDEF UseMouse}
ShowMousePrim(SaveMouse);
{$ENDIF}
end;
procedure ErrorProc(UnitCode : Byte; var ErrCode : Word; Msg : string);
{-Error handler}
var
I : Word;
CursorSL, CursorXY : Word;
begin
{save the cursor position and shape}
GetCursorState(CursorXY, CursorSL);
{clear the status line}
ClearPromptLine;
{display the error message}
NormalCursor;
if Msg = '' then Msg := 'Internal error '+Long2Str(ErrCode);
DisplayMessage(' '+Msg+'. Press any key...');
{wait for a keypress}
I := ReadKeyWord;
{clear the prompt line}
ClearPromptLine;
{Restore cursor position and shape}
RestoreCursorState(CursorXY, CursorSL);
end;
function EditFunc(MsgCode : Word;
Prompt : string;
ForceUp : Boolean;
TrimBlanks : Boolean;
MaxLen : Byte;
var S : string) : Boolean;
{-Line editing routine}
var
LE : LineEditor;
eWidth : Byte;
begin
with LE do begin
Init(BigEdColors);
if ForceUp then
leEditOptionsOn(leForceUpper)
else
leEditOptionsOff(leForceUpper);
if TrimBlanks then
leEditOptionsOn(leTrimBlanks)
else
leEditOptionsOff(leTrimBlanks);
Prompt := Prompt+' ';
if Length(Prompt)+MaxLen > ScreenWidth then
eWidth := ScreenWidth-Length(Prompt)
else
eWidth := MaxLen;
ClearPromptLine;
ReadString(Prompt, PromptLine, 1, MaxLen, eWidth, S);
EditFunc := (GetLastCommand <> ccQuit);
ClearPromptLine;
end;
end;
function YesNoFunc(MsgCode : Word; Prompt : string;
Default : Byte; QuitAndAll : Boolean) : Byte;
{-Get a response to a yes-no question}
var
LE : LineEditor;
Ch : Char;
CharsToTake : CharSet;
begin
with LE do begin
ClearPromptLine;
Init(BigEdColors);
leEditOptionsOn(leAllowEscape+leDefaultAccepted+leForceUpper);
if Default = beYes then
Ch := 'Y'
else
Ch := 'N';
if QuitAndAll then begin
CharsToTake := ['Y', 'N', 'A', 'Q'];
Prompt := Prompt+' (Y/N/A/Q)'
end
else
CharsToTake := ['Y', 'N'];
ClearPromptLine;
ReadChar(Prompt, PromptLine, 1, CharsToTake, Ch);
if GetLastCommand = ccQuit then
YesNoFunc := beQuit
else case Ch of
'Y' : YesNoFunc := beYes;
'N' : YesNoFunc := beNo;
'A' : YesNoFunc := beAll;
'Q' : YesNoFunc := beQuit;
end;
ClearPromptLine;
end;
end;
function PickFileName(var Mask : PathStr) : Word;
var
Dir : DirListPtr;
begin
New(Dir, InitCustom(20, 5, 60, 20, BigEdColors, DefWindowOptions or wBordered,
MaxAvail, PickVertical, SingleFile));
if Dir = nil then begin
PickFileName := InitStatus;
exit;
end;
with Dir^ do begin
wFrame.AddShadow(shBR, shSeeThru);
diOptionsOn(diOptimizeSize);
AddMaskHeader(True, 1, 30, heTC);
PickFileName := GetFileName(Trim(Mask), AnyFile, Mask);
end;
Dispose(Dir, Done);
end;
function GetFileFunc(MsgCode : Word; Prompt : string;
ForceUp, TrimBlanks, Writing, MustExist : Boolean;
MaxLen : Byte; DefExt : ExtStr;
var S : string) : Boolean;
{-Get a filename}
var
I : Word;
begin
GetFileFunc := False;
if NOT(EditFunc(0, Prompt, ForceUp, TrimBlanks, MaxLen, S)) then
exit;
if (Pos('*', S) > 0) or (Pos('?', S) > 0) then begin
if PickFileName(S) <> 0 then
exit;
end;
if Writing then
if ExistFile(S) then
GetFileFunc := YesNoFunc(0, 'File exists. Overwrite it?', beNo, False) = beYes
else
GetFileFunc := True
else if (NOT(MustExist)) or (ExistFile(S)) then
GetFileFunc := True
else begin
I := 0;
ErrorProc(0, I, 'File not found');
end;
end;
{----------------------------------------------------------------------------}
constructor MyBigEditor.InitCustom(UX, UY, LX, LY : Byte;
var Colors : ColorSet;
WinOpts : LongInt);
begin
if not BigEditor.InitCustom(UX, UY, LX, LY, Colors, WinOpts) then Fail;
CompileMode := cmMake;
CompileType := ctTPC;
end;
destructor MyBigEditor.Done;
begin
BigEditor.Done;
end;
function MyBigEditor.FindCompileError : Boolean;
var S, T : String;
I, N : Integer;
B : Boolean;
begin
B := False;
{scan the screen, looking for our telltale}
for I := 1 to ScreenHeight do begin
FastRead(ScreenWidth, I, 1, S);
if Pos('): Error', S) > 0 then begin
{found the telltale}
B := True;
Report := S;
{get the file-in-error's name...}
NFName := Copy(S, 1, Pred(Pos('(', S)));
{...and the line of the error}
T := Copy(S, Pos('(', S)+1, 5);
while (Length(T) > 0) and (NOT(T[length(T)] in ['0'..'9'])) do Dec(T[0]);
if Str2Int(T, LC) then begin
{scan forward, looking for the ^ that indicates the col of the error}
N := 0; CC := I;
while CC <= ScreenHeight do begin
Inc(CC);
{if N > 0, then error col is past the right screen margin}
Inc(N);
FastRead(ScreenWidth, CC, 1, S);
if Trim(S) = '^' then begin
{found the caret, get the col count}
CC := Pos('^', S) + (80 * Pred(N div 2));
exit;
end;
end;
end;
end;
end;
FindCompileError := B;
if NOT B then
NFName := '';
{an error report that doesn't contain line/col info, just report it}
for I := ScreenHeight downto 1 do begin
{scan from bottom up; first non-blank line is our report}
FastRead(ScreenWidth, I, 1, Report);
Report := Trim(Report);
if Report <> '' then exit;
end;
end;
procedure MyBigEditor.FindCompileGood;
var S : String;
I : Integer;
begin
for I := 1 to ScreenHeight do begin
{look for our telltale}
FastRead(ScreenWidth, I, 1, S);
if Pos(' lines, ', S) > 0 then begin
{found it}
Report := S;
exit;
end;
end;
end;
procedure MyBigEditor.CallCompiler(CType : CompType; CMode : CompMode);
var
S, T : PathStr;
I : Integer;
L : LongInt;
F : Boolean;
B : Boolean;
CX, CL : Word;
begin
{$IFDEF UseMouse}
if (MouseInstalled) then begin
HideMousePrim(B);
{$IFDEF UseDrag}
RemoveISRs;
{$ELSE}
DisableEventHandling;
{$ENDIF}
end;
{$ENDIF}
S := CompCmds[CType];
if S = '' then begin
GotError(epNonFatal+ecStringNotFound, 'No compiler/assembler assigned');
exit;
end;
if beOptionsAreOn(beModified) then
SaveFile;
if not(CType in [ctTPC, ctTPCX, ctTPCW]) then begin
CMode := cmCustom;
MainFile := bePathName;
end;
if CType = ctTD then
S := S + ' ' + JustName(MainFile)
else begin
S := S + ' ' + CompDefOpts[CType]+' ';
case CMode of
cmBuild:
S := S + '/B';
cmErrSrch:
begin
T := '';
if not Edit(0, 'Error address:', True, True, 10, T) then exit;
S := S + '/F' + T;
end;
cmCustom:
begin
T := '';
if not Edit(0, 'Options:', True, True, 64, T) then exit;
S := CompCmds[CType] + ' ' + T;
end;
end;
S := S + ' ' + MainFile;
end;
TBW^.Draw;
TBW^.Clear;
Report := '';
{call the compiler}
I := ExecDosSwap(S, False, NIL, SwapFilePath);
case CType of
ctTPC, ctTPCX, ctTPCW :
begin
if DOSExitCode <> 0 then begin
{find the error}
F := FindCompileError;
{redraw our editor window}
if F then begin
if (NFName <> '') and (NFName <> bePathName) then begin
{file-in-error different from our last edit file, so switch}
{this restores the new file's state if it's been loaded before}
ReadFile(NFName, L);
end;
{jump to the line/col of the error}
GoToLineCol(LC, CC);
end;
end
else
{good compile, just redraw the editor and the report}
FindCompileGood;
end;
ctTASM:
if DOSExitCode <> 0 then begin
if WhereY = ScreenHeight then
ScrollWindowUp(1, 1, ScreenWidth, ScreenHeight, 1);
FastWrite(Center('Press a key...', ScreenWidth), ScreenHeight, 1, ColorMono($4F, $70));
if ReadKeyWord = 0 then ;
end;
end;
TBW^.Erase;
beOptionsOn(beForceRedraw);
UpdateContents;
GetCursorState(CX, CL);
DisplayMessage(' '+Report);
RestoreCursorState(CX, CL);
{$IFDEF UseMouse}
if (MouseInstalled) then begin
{$IFDEF UseDrag}
InstallISRs;
{$ELSE}
EnableEventHandling;
with BigEdColors do
SoftMouseCursor($0000, (ColorMono(MouseColor, MouseMono) SHL 8) + $04);
{$ENDIF}
ShowMousePrim(B);
end;
{$ENDIF}
end;
procedure MyBigEditor.ShowBackground;
begin
TBW^.Draw;
if ReadKeyWord = 0 then ;
TBW^.Erase;
end;
procedure MyBigEditor.SelectCompiler;
var
S : ExtStr;
begin
S := JustExtension(bePathName);
S := StUpcase(S);
if S = 'ASM' then
CompileType := ctTASM
else
CompileType := ctTPC;
end;
procedure MyBigEditor.DosShell(Cmd : String);
var
S : String;
I : Integer;
F : Boolean;
B : Boolean;
begin
{$IFDEF UseMouse}
if (MouseInstalled) then begin
HideMousePrim(B);
{$IFDEF UseDrag}
RemoveISRs;
{$ELSE}
DisableEventHandling;
{$ENDIF}
end;
{$ENDIF}
S := GetEnv('COMSPEC');
if Cmd <> '' then
S := S+' /C '+Cmd;
{draw the background window for the shell}
TBW^.Draw;
TBW^.Clear;
if Cmd = '' then
WriteLn('DOS Shell - "EXIT" to return to editor.');
{call the shell}
I := ExecDOSSwap(S, False, NIL, SwapFilePath);
if Cmd <> '' then begin
if WhereY = ScreenHeight then
ScrollWindowUp(1, 1, ScreenWidth, ScreenHeight, 1);
FastWrite(Center('Press a key...', ScreenWidth), ScreenHeight, 1, ColorMono($4F, $70));
if ReadKeyWord = 0 then ;
end;
TBW^.Erase;
beOptionsOn(beForceRedraw);
UpdateContents;
{$IFDEF UseMouse}
if (MouseInstalled) then begin
{$IFDEF UseDrag}
InstallISRs;
{$ELSE}
EnableEventHandling;
with BigEdColors do
SoftMouseCursor($0000, (ColorMono(MouseColor, MouseMono) SHL 8) + $04);
{$ENDIF}
ShowMousePrim(B);
end;
{$ENDIF}
end;
procedure MyBigEditor.PerformDosCommand;
var
S : String;
begin
S := '';
if NOT(EditFunc(0, 'DOS Cmd:', False, True, 132, S)) then exit;
DOSShell(S);
end;
procedure MyBigEditor.ExecuteSelf;
var
S : String;
begin
S := ForceExtension(bePathName, 'EXE');
DOSShell(S);
end;
procedure MyBigEditor.SaveState(var S);
begin
with SpcStateRec(S) do begin
BigEditor.SaveState(SSR);
CT := CompileType;
end;
end;
procedure MyBigEditor.RestoreState(var S);
begin
with SpcStateRec(S) do begin
BigEditor.RestoreState(SSR);
CompileType := CT;
end;
end;
procedure MyBigEditor.ReadFile(FName : string; var FSize : LongInt);
var
P : FileNodePtr;
S : SpcStateRec;
begin
DisplayMessage('Reading...');
FName := DefaultExtension(FName, beDefExt);
FName := FExpand(FName);
BigEditor.ReadFile(FName, FSize);
P := FindFileInList(FName);
if P <> nil then
RestoreState(P^.State)
else begin
SelectCompiler;
SaveState(S);
AddFileToList(FName, S);
end;
ClearPromptLine;
end;
procedure MyBigEditor.SaveFile;
var
S : SpcStateRec;
begin
DisplayMessage('Saving...');
BigEditor.SaveFile;
SaveState(S);
AddFileToList(bePathName, S);
ClearPromptLine;
end;
procedure MyBigEditor.NewFilePrompted;
var
S : SpcStateRec;
begin
SaveState(S);
AddFileToList(bePathName, S);
BigEditor.NewFilePrompted;
MainFile := bePathName;
end;
procedure Abort(S : String);
begin
WriteLn('Fatal: '+S);
Halt(1);
end;
function InitEdWin(var Ed : MyBigEditorPtr; IsNewFile : Boolean; var FN : PathStr) : Word;
var
FS : LongInt;
W : Word;
begin
New(Ed, InitCustom(1, 3, ScreenWidth, ScreenHeight, BigEdColors,
DefWindowOptions));
if Ed = nil then begin
InitEdWin := InitStatus;
exit;
end;
with Ed^ do begin
AdjustFrameCoords(1, 1, ScreenWidth, ScreenHeight);
SetStatusProc(Status);
SetEditProc(EditFunc);
SetYesNoProc(YesNoFunc);
SetGetFileProc(GetFileFunc);
SetErrorProc(ErrorProc);
SetDefaultExtension('PAS');
W := RawError;
InitEdWin := W;
if W <> 0 then exit;
if IsNewFile then begin
if (FN = '') or (HasWildCards(FN)) then begin
if not GetFile(0, 'File name:', True, True, False, False, 80, beDefExt, FN) then begin
Dispose(Ed, Done);
Ed := nil;
InitEdWin := $FFFF;
exit;
end;
end;
if FN <> '' then
FN := DefaultExtension(FN, beDefExt);
ReadFile(FN, FS);
if cwGetLastError <> 0 then begin
InitEdWin := cwGetLastError;
Dispose(Ed, Done);
Ed := nil;
exit;
end;
MainFile := bePathName;
FN := '*.PAS';
end;
end;
end;
procedure InitSystem;
var
MX : Byte;
begin
if OpDos.DosVersion < $0300 then
Abort('This program requires DOS version 3.0 or higher.');
FilesList.Init;
New(TBW, Init(1, 1, ScreenWidth, ScreenHeight));
if TBW = nil then
Abort('Error '+Long2Str(InitStatus mod 10000)+' initializing screen management');
{$IFDEF UseMouse}
if (MouseInstalled) then begin
{$IFDEF UseDrag}
with BigEdColors do
MX := ColorMono(MouseColor, MouseMono);
BigEditorCommands.SetMouseCursor((MX shl 8) + NormMouse,
(MX shl 8) + MoveMouse,
(MX shl 8) + ResizeMouse);
{$ELSE}
EnableEventHandling;
with BigEdColors do
SoftMouseCursor($0000, (ColorMono(MouseColor, MouseMono) SHL 8) + NormMouse);
BigEditorCommands.cpOptionsOn(cpEnableMouse);
{$ENDIF}
end;
{$ENDIF}
with BigEditorCommands do begin
SetUserHookProc(UserHook);
AddCommand(ccAbandonFile, 1, AltX, 0);
AddCommand(ccUser1, 1, AltS, 0); {Dos Shell}
AddCommand(ccUser2, 1, F9, 0); {Make}
AddCommand(ccUser3, 1, AltF9, 0); {Build}
AddCommand(ccUser4, 1, CtrlF9, 0); {Find error}
AddCommand(ccUser5, 1, ShF9, 0); {Custom}
AddCommand(ccUser6, 1, AltF8, 0); {Toggle compiler type}
AddCommand(ccUser7, 1, F8, 0); {debug}
AddCommand(ccUser8, 1, AltF10, 0); {show compile screen}
end;
ClrScr;
end;
procedure Main;
var
W : Word;
FN : PathStr;
Fin : Boolean;
begin
InitSystem;
if ParamCount = 0 then
FN := '*.PAS'
else
FN := ParamStr(1);
W := InitEdWin(BE, True, FN);
if W <> 0 then
Abort('Error '+Long2Str(W mod 10000)+' initializing Editor');
with BE^ do begin
Draw;
ClearPromptLine;
Fin := False;
repeat
Process;
case GetLastCommand of
ccUser1:
PerformDosCommand;
ccUser2:
CallCompiler(CompileType, cmMake);
ccUser3:
CallCompiler(CompileType, cmBuild);
ccUser4:
CallCompiler(CompileType, cmErrSrch);
ccUser5:
CallCompiler(CompileType, cmCustom);
ccUser6:
if CompileType = ctTASM then
CompileType := ctTPC
else
Inc(CompileType);
ccUser7:
CallCompiler(ctTD, cmCustom);
ccUser8:
ShowBackground;
ccSaveExit,
ccQuit,
ccAbandonFile:
begin
if beOptionsAreOn(beModified) then
if YesNo(0, emFileModified, beYes, False) = beYes then
SaveFile;
DisplayMessage('Working...');
LList^.Clean;
DisplayMessage('');
Fin := True;
end;
else
Fin := True;
end;
until Fin;
Erase;
end;
Dispose(BE, Done);
Dispose(TBW,Done);
FilesList.Done;
ClrScr;
end;
end.